<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layouts/layout}">
<!-- BEGIN HEAD -->
<head>
    <title>消息供应商管理</title>
    <style>
        table tr:nth-child(even){
            background: #F5F5F5;
        }
    </style>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
<th:block layout:fragment="content">
    <!-- BEGIN PAGE CONTAINER-->
    <div class="container-fluid">
        <!-- BEGIN PAGE HEADER-->
        <!-- END PAGE HEADER-->
        <!-- BEGIN PAGE CONTENT-->
        <div class="portlet-body form">
            <div class="row-fluid">
                <div class="span9">
                    <div class="control-group">
                        <div class="controls">
                            <!--<button id="submitBtn" class="btn btn-sm btn-info green"
                                    onclick="javascript:location.href='/supplier/edit?supplierId=0'">新建
                            </button>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row-fluid">
            <!-- BEGIN SIDEBAR -->
            <div class="span12">
                <!-- BEGIN SAMPLE FORM PORTLET-->
                <div class="portlet">
                    <div class="portlet-body form">
                        <!-- BEGIN FORM-->
                        <table id="table"></table>
                    </div>
                </div>
                <!-- END SAMPLE FORM PORTLET-->
            </div>
        </div>
        <!-- END PAGE CONTENT-->
    </div>
    <!-- END PAGE CONTAINER-->
</th:block>
<th:block layout:fragment="content-js">
    <script th:inline="javascript">
        $(function () {
            initTable();
        });

        function initTable() {
            $("#table").bootstrapTable({
                dataType: "json",
                method: 'post',
                contentType: "application/x-www-form-urlencoded",
                cache: false,
                url: "/supplier/listAll",
                columns: [
                    {
                        field: 'id',
                        title: 'id',
                        align: 'center'
                    },
                    {
                        field: 'type',
                        title: '类型',
                        align: 'center',
                        formatter: function (value,
                                             row, index) {
                            if (value == '1') {
                                return '短信';
                            }
                            if (value == '2') {
                                return '邮件';
                            }
                            if (value == '3') {
                                return '推送';
                            }
                        }
                    },
                    {
                        field: 'name',
                        title: '供应商名称',
                        align: 'center'
                    },
                    {
                        field: 'timesLimitPerDay',
                        title: '每天次数限制',
                        align: 'center'
                    },
                    {
                        field: 'outerAppKey',
                        title: '外部appkey',
                        align: 'center'
                    }
                ]
            })
        }

        function changeStatus(id, status) {
            $.ajax({
                type: 'post',
                async: true,
                url: '/supplier/changeStatus',
                data: "id=" + id + "&status=" + status,
                success: function (data) {
                    if (data.code == "0000") {
                        location.href="/supplier/list";
                    } else {
                        alert("操作失败:"+data.msg);
                        return false;
                    }
                }
            });
        }
    </script>

</th:block>
</body>
<!-- END BODY -->
</html>